import { createParamDecorator, ExecutionContext, BadRequestException } from '@nestjs/common';
import { Request } from 'express';
import { UserToken } from 'src/entities/user.token';
import business from 'src/common/business';

export const UserInfo = createParamDecorator(async (_, context: ExecutionContext) => {
    const request = context.switchToHttp().getRequest<Request>();
    let authorization = request.header(`tokenauthorization`);
    let user: UserToken = business.jwtDecrypt(authorization.toString());
    return user;
})